package com.example.Lezedata.ui.dataPage.subVc;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.example.Lezedata.R;
import com.example.Lezedata.util.GBUtil;

import bid.Bid;

public class ChequeDetailListCell extends LinearLayout {

    public Bid.ChequesRecord pool;
    private TextView textViewAddress;
    private TextView textViewType;
    private TextView textViewState;
    private TextView textViewPayout;
    public static ChequeDetailListCell newInstance(Context context , ViewGroup viewGroup) {
        ChequeDetailListCell cell = (ChequeDetailListCell)LayoutInflater.from(context).inflate(R.layout.cheque_detail_list_cell,viewGroup,false);
        return cell;
    }

    public ChequeDetailListCell(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        textViewAddress = findViewWithTag("address");
        textViewType = findViewWithTag("type");
        textViewState = findViewWithTag("state");

        textViewPayout=findViewById(R.id.textView_payout);
    }

    public void setPool(Bid.ChequesRecord pool) {
        this.pool = pool;

        String type = "转入";
        String state = "有效";
        if (pool.getStatus() == Bid.ChequeStatus.CS_INVAILD){
             type = "转出";
             state = "无效";
        }
        textViewAddress.setText(pool.getId());
        textViewType.setText(type);
        textViewState.setText(state);
        textViewPayout.setText(GBUtil.formatPrice( pool.getPayout(),false));
    }
}
